#include "C3DTriangle.h"

C3DTriangle::C3DTriangle(void)
{
	m_point[0]=C3DPoint(0,0,0);
	m_point[1]=C3DPoint(0,0,0);
	m_point[2]=C3DPoint(0,0,0);
	m_texIndex = 0;
}

C3DTriangle::C3DTriangle( const C3DTriangle& t)
{
	m_point[0]=t.m_point[0];
	m_point[1]=t.m_point[1];
	m_point[2]=t.m_point[2];
}

C3DTriangle::C3DTriangle( C3DPoint& p1,C3DPoint& p2,C3DPoint& p3 )
{
	m_point[0]=p1;
	m_point[1]=p2;
	m_point[2]=p3;
}
C3DTriangle::~C3DTriangle(void)
{
}

C3DTriangle& C3DTriangle::operator=( const C3DTriangle& t)
{
	if(this==&t)
		return *this;
	m_point[0]=t.m_point[0];
	m_point[1]=t.m_point[1];
	m_point[2]=t.m_point[2];
}

void C3DTriangle::CalculateNormal()
{
	C3DPoint U = m_point[1]-m_point[0];
	C3DPoint V = m_point[2]-m_point[0];
	m_normal.m_x = U.m_y*V.m_z - U.m_z*V.m_y;
	m_normal.m_y = U.m_z*V.m_x - U.m_x*V.m_z;
	m_normal.m_z = U.m_x*V.m_y - U.m_y*V.m_x;


}